/*
 * file.c
 *
 *  Created on: 10 Oct 2012
 *      Author: michael
 */
#include "../../include/shredder.h"

#include <stdio.h>
#include <errno.h>

int shredder_have_write_permissions(const char *filename) {
	FILE *fp = fopen(filename, "w");
	if(!fp && (errno == EACCES)) return 0;
	else if(fp) return 1;
	return -1;
}

int shredder_get_file_size(const char *filename) {
	FILE *fp = fopen(filename, "r");
	if(!fp) return -1;
	fseek(fp, 0, SEEK_END);
	int size = ftell(fp);
	fclose(fp);
	return size;
}
